package com.m.springblog.mapper;

import com.m.springblog.model.BlogInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BlogInfoMapper {
    /**
     * 获取博客列表
     */
    @Select("select * from blog_info where delete_flag = 0 order by create_time desc")
    List<BlogInfo> queryBlogList();
    /**
     * 根据博客ID, 获取博客详情
     */
    @Select("select * from blog_info where id = #{id} and delete_flag = 0")
    BlogInfo queryBlogById(Integer id);
    /**
     * 编辑博客
     */
    @Update("update blog_info set title = #{title}, content=#{content} where id=#{id}")
    Integer updateBlog(BlogInfo blogInfo);
    /**
     * 删除博客
     */
    @Update("update blog_info set delete_flag = 1 where id = #{id}")
    Integer deleteBlog(Integer id);
    /**
     * 添加博客
     */
    @Insert("insert into blog_info (title,content, user_id) values (#{title},#{content},#{userId})")
    Integer insertBlog(BlogInfo blogInfo);
}
